Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LineReader class for reading lines from file stream #1130

Merged
merged 1 commit into from Jul 6, 2013
Merged

LineReader class for reading lines from file stream #1130

merged 1 commit into from Jul 6, 2013

Conversation

gsomix
Copy link
Contributor

@gsomix gsomix commented May 26, 2013

  • LineReader with test
  • CircularBuffer with test

valgrind --leak-check=full ./library_circularbuffer
==9537== Memcheck, a memory error detector
==9537== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==9537== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==9537== Command: ./library_circularbuffer
==9537==
==9537==
==9537== HEAP SUMMARY:
==9537== in use at exit: 0 bytes in 0 blocks
==9537== total heap usage: 241 allocs, 241 frees, 42,576 bytes allocated
==9537==
==9537== All heap blocks were freed -- no leaks are possible
==9537==
==9537== For counts of detected and suppressed errors, rerun with: -v
==9537== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)

valgrind --leak-check=full ./io_linereader
==9542== Memcheck, a memory error detector
==9542== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==9542== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==9542== Command: ./io_linereader
==9542==
==9542==
==9542== HEAP SUMMARY:
==9542== in use at exit: 0 bytes in 0 blocks
==9542== total heap usage: 374 allocs, 374 frees, 49,045 bytes allocated
==9542==
==9542== All heap blocks were freed -- no leaks are possible
==9542==
==9542== For counts of detected and suppressed errors, rerun with: -v
==9542== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)

}

// look for the delimiter in the read data
newline_pos=(char*) memchr(current_pos, '\n', bytes_read);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please make this configurable, maybe even support sets of characters. you can very efficiently do this by defining a byte delimiters[256] array that has 1's at positions that should be delimiters, e.g. delimiters['\n']=1;

This would help e.g. csv parsing.

sonney2k pushed a commit that referenced this pull request Jul 6, 2013
LineReader class for reading lines from file stream
@sonney2k sonney2k merged commit db2aecf into shogun-toolbox:develop Jul 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants